import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/*
    拷贝的过程就是一边读一边写，牛牛
 */
public class FileCopyTest01 {
    public static void main(String[] args) {
        FileInputStream fis = null;
        FileOutputStream fos = null;
        try {
            fis = new FileInputStream("F:\\course\\01-JavaSE\\原理图\\IO流\\1.IO流概述.png");
            fos = new FileOutputStream("F:\\course\\1.IO流概述.png");

            //一边读一边写
            byte[] bytes = new byte[1024 * 1024]; //每次读取1Mb文件
            int readData = 0;
            while ((readData = fis.read(bytes)) != -1){
                fos.write(bytes,0,readData);
            }
            fos.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}
